{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import catboost as cat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def reduce_mem_usage(df):\n",
    "    \"\"\" iterate through all the columns of a dataframe and modify the data type\n",
    "        to reduce memory usage.        \n",
    "    \"\"\"\n",
    "    start_mem = df.memory_usage().sum() \n",
    "    \n",
    "    for col in df.columns:\n",
    "        col_type = df[col].dtype\n",
    "        \n",
    "        if col_type != object:\n",
    "            c_min = df[col].min()\n",
    "            c_max = df[col].max()\n",
    "            if str(col_type)[:3] == 'int':\n",
    "                if c_min > np.iinfo(np.int8).min and c_max < np.iinfo(np.int8).max:\n",
    "                    df[col] = df[col].astype(np.int8)\n",
    "                elif c_min > np.iinfo(np.int16).min and c_max < np.iinfo(np.int16).max:\n",
    "                    df[col] = df[col].astype(np.int16)\n",
    "                elif c_min > np.iinfo(np.int32).min and c_max < np.iinfo(np.int32).max:\n",
    "                    df[col] = df[col].astype(np.int32)\n",
    "                elif c_min > np.iinfo(np.int64).min and c_max < np.iinfo(np.int64).max:\n",
    "                    df[col] = df[col].astype(np.int64)  \n",
    "            else:\n",
    "                if c_min > np.finfo(np.float16).min and c_max < np.finfo(np.float16).max:\n",
    "                    df[col] = df[col].astype(np.float16)\n",
    "                elif c_min > np.finfo(np.float32).min and c_max < np.finfo(np.float32).max:\n",
    "                    df[col] = df[col].astype(np.float32)\n",
    "                else:\n",
    "                    df[col] = df[col].astype(np.float64)\n",
    "        else:\n",
    "            df[col] = df[col].astype('category')\n",
    "\n",
    "    end_mem = df.memory_usage().sum() \n",
    "\n",
    "    return df\n",
    "\n",
    "def load_data(path):\n",
    "    user = reduce_mem_usage(pd.read_csv(path + 'user.csv',header=None, engine='c'))\n",
    "    item = reduce_mem_usage(pd.read_csv(path + 'item.csv',header=None, engine='c'))\n",
    "    data = pd.read_csv(path + 'user_behavior.csv',header=None, engine='c')\n",
    "\n",
    "    data.columns = ['userID','itemID','behavior','timestamp']\n",
    "    data['day'] = data['timestamp'] // 86400\n",
    "    data['hour'] = data['timestamp'] // 3600 % 24\n",
    "    \n",
    "    ## 生成behavior的onehot\n",
    "    for i in ['pv','fav','cart','buy']:\n",
    "        data[i] = 0\n",
    "        data.loc[data['behavior'] == i, i] = 1\n",
    "\n",
    "    ## 生成behavior的加权\n",
    "    \n",
    "    data['day_hour'] = data['day'] + data['hour'] / float(24)\n",
    "    data.loc[data['behavior']=='pv','behavior'] = 1\n",
    "    data.loc[data['behavior']=='fav','behavior'] = 2\n",
    "    data.loc[data['behavior']=='cart','behavior'] = 3\n",
    "    data.loc[data['behavior']=='buy','behavior'] = 1\n",
    "    max_day = max(data['day'])\n",
    "    min_day = min(data['day'])\n",
    "    data['behavior'] = (1 - (max_day-data['day_hour']+2)/(max_day-min_day+2)) * data['behavior'] \n",
    "\n",
    "    item.columns = ['itemID','category','shop','brand']\n",
    "    user.columns = ['userID','sex','age','ability']\n",
    "    \n",
    "    data = reduce_mem_usage(data)\n",
    "\n",
    "    data = pd.merge(left=data, right=item, on='itemID',how='left', sort=False)\n",
    "    data = pd.merge(left=data, right=user, on='userID',how='left', sort=False)\n",
    "\n",
    "    return user, item, data\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "user, item, data = load_data(path = '../ECommAI_EUIR_round2_train_20190816/')\n",
    "user['age'] = user['age'] // 10\n",
    "data['age'] = data['age'] // 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#########需要修改！！！！！！！！\n",
    "###路径也要改\n",
    "recall_train_list = []\n",
    "for i in range(7):\n",
    "    recall_train_list.append(\n",
    "        reduce_mem_usage(pd.read_csv(str(i) + 'recall_list_round2_15day_300lenth-Copy1.csv', engine='c')))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "recall_train = pd.concat(recall_train_list, sort=False)\n",
    "recall_train = recall_train.fillna(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "def downsample(df, percent=10):\n",
    "    '''\n",
    "    percent:多数类别下采样的数量相对于少数类别样本数量的比例\n",
    "    '''\n",
    "    \n",
    "    data1 = df[df['label'] != 0]\n",
    "    data0 = df[df['label'] == 0]\n",
    "    index = np.random.randint(len(data0), size = percent * len(data1))\n",
    "    lower_data0 = data0.iloc[list(index)]\n",
    "    \n",
    "    return(pd.concat([lower_data0, data1]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "recall_train = downsample(recall_train,10 )\n",
    "\n",
    "recall_train = pd.merge(left=recall_train, right=item, on='itemID',how='left', sort=False)\n",
    "recall_train = pd.merge(left=recall_train, right=user, on='userID',how='left', sort=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "feature_path = '../Step2 Generate_feature_for_Ranking/'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "underline_features_files = [\n",
    "'brand_count.csv',\n",
    "'brand_sum.csv',\n",
    "'category_count.csv',\n",
    "'category_sum.csv',\n",
    "'itemID_count.csv',\n",
    "'itemID_sum.csv',\n",
    "'shop_count.csv',\n",
    "'shop_sum.csv',\n",
    "'category_lower.csv',\n",
    "'item_rank.csv',\n",
    "'category_higher.csv',\n",
    "'itemID_higher.csv',\n",
    "]\n",
    "\n",
    "underline_features = []\n",
    "for f in underline_features_files:\n",
    "    underline_features.append(pd.read_csv(feature_path+f, engine='c'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "for f in underline_features:\n",
    "    recall_train = pd.merge(left=recall_train, right=f, on=f.columns[0], how='left', sort=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "## 注意这个线下训练时 是underline\n",
    "\n",
    "double_underline_features_files = [\n",
    "'item_to_ability_count_underline.csv',\n",
    "'item_to_sex_count_underline.csv',\n",
    "'item_to_age_count_underline.csv',\n",
    "]\n",
    "\n",
    "double_underline_features = []\n",
    "for f in double_underline_features_files:\n",
    "    double_underline_features.append(pd.read_csv(feature_path+f, engine='c'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "for f in double_underline_features:\n",
    "    recall_train = pd.merge(left=recall_train, right=f, on=list(f.columns[0: 2]), how='left', sort=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "## 注意这个线下训练时 是underline\n",
    "\n",
    "time_features_files = [\n",
    "'itemID_last_time_underline.csv',\n",
    "'brand_last_time_underline.csv',\n",
    "'shop_last_time_underline.csv'\n",
    "]\n",
    "\n",
    "time_features = []\n",
    "for f in time_features_files:\n",
    "    time_features.append(pd.read_csv(feature_path+f, engine='c'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "for f in time_features:\n",
    "    recall_train = pd.merge(left=recall_train, right=f, on=f.columns[0], how='left', sort=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "online_features_files =  ['user_to_brand_count.csv',\n",
    "'user_to_brand_sum.csv',\n",
    "'user_to_category_count.csv',\n",
    "'user_to_category_sum.csv',\n",
    "'user_to_shop_count.csv',\n",
    "'user_to_shop_sum.csv',]\n",
    "\n",
    "\n",
    "online2 = ['user_to_category_count_pv.csv',\n",
    " 'user_to_category_count_buy.csv',\n",
    " 'user_to_shop_count_pv.csv',\n",
    " 'user_to_shop_count_buy.csv',\n",
    " 'user_to_brand_count_pv.csv',\n",
    " 'user_to_brand_count_buy.csv']\n",
    "\n",
    "\n",
    "online3 = ['user_to_category_count_yestday.csv',\n",
    "'user_to_category_count_pv_yestday.csv',\n",
    " 'user_to_category_count_buy_yestday.csv',\n",
    " 'user_to_shop_count_pv_yestday.csv',\n",
    " 'user_to_shop_count_buy_yestday.csv',\n",
    " 'user_to_brand_count_pv_yestday.csv',\n",
    " 'user_to_brand_count_buy_yestday.csv']\n",
    "\n",
    "online4 = [\n",
    " 'user_to_category_count_5days.csv',\n",
    " 'user_to_category_count_pv_5days.csv',\n",
    " 'user_to_category_count_buy_5days.csv',\n",
    " 'user_to_shop_count_pv_5days.csv',\n",
    " 'user_to_shop_count_buy_5days.csv',\n",
    " 'user_to_brand_count_pv_5days.csv',\n",
    " 'user_to_brand_count_buy_5days.csv']\n",
    "\n",
    "online5 = [\n",
    "'user_to_shop_lasttime.csv',\n",
    "'user_to_category_lasttime.csv',\n",
    "'user_to_brand_lasttime.csv' ,\n",
    "]\n",
    "\n",
    "online_features_files = online_features_files + online2 + online3 + online4 + online5\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "online_features = []\n",
    "for f in online_features_files:\n",
    "    online_features.append(pd.read_csv(feature_path+f, engine='c'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [],
   "source": [
    "for f in online_features:\n",
    "    recall_train = pd.merge(left=recall_train, right=f, on=list(f.columns[0: 2]), how='left', sort=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "def transfer_label(x):\n",
    "    if x == 0:\n",
    "        return 0\n",
    "    else:\n",
    "        return 1\n",
    "\n",
    "recall_train['label'] = recall_train['label'].apply(transfer_label)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
    "features = [x for x in recall_train.columns if x not in ['itemID','userID','category','shop','brand','label','apriori_rank','apriori_top']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0:\tlearn: 0.5969336\ttotal: 617ms\tremaining: 3m 4s\n",
      "1:\tlearn: 0.5237747\ttotal: 1.2s\tremaining: 2m 58s\n",
      "2:\tlearn: 0.4676843\ttotal: 1.74s\tremaining: 2m 51s\n",
      "3:\tlearn: 0.4248270\ttotal: 2.24s\tremaining: 2m 46s\n",
      "4:\tlearn: 0.3923313\ttotal: 2.78s\tremaining: 2m 44s\n",
      "5:\tlearn: 0.3675028\ttotal: 3.31s\tremaining: 2m 41s\n",
      "6:\tlearn: 0.3480424\ttotal: 3.85s\tremaining: 2m 41s\n",
      "7:\tlearn: 0.3332812\ttotal: 4.37s\tremaining: 2m 39s\n",
      "8:\tlearn: 0.3221164\ttotal: 4.84s\tremaining: 2m 36s\n",
      "9:\tlearn: 0.3126932\ttotal: 5.33s\tremaining: 2m 34s\n",
      "10:\tlearn: 0.3053910\ttotal: 5.8s\tremaining: 2m 32s\n",
      "11:\tlearn: 0.2996877\ttotal: 6.35s\tremaining: 2m 32s\n",
      "12:\tlearn: 0.2950420\ttotal: 6.92s\tremaining: 2m 32s\n",
      "13:\tlearn: 0.2915425\ttotal: 7.41s\tremaining: 2m 31s\n",
      "14:\tlearn: 0.2886570\ttotal: 7.98s\tremaining: 2m 31s\n",
      "15:\tlearn: 0.2865094\ttotal: 8.53s\tremaining: 2m 31s\n",
      "16:\tlearn: 0.2846760\ttotal: 8.98s\tremaining: 2m 29s\n",
      "17:\tlearn: 0.2833095\ttotal: 9.43s\tremaining: 2m 27s\n",
      "18:\tlearn: 0.2818918\ttotal: 9.99s\tremaining: 2m 27s\n",
      "19:\tlearn: 0.2807000\ttotal: 10.5s\tremaining: 2m 27s\n",
      "20:\tlearn: 0.2797297\ttotal: 11.1s\tremaining: 2m 26s\n",
      "21:\tlearn: 0.2789706\ttotal: 11.5s\tremaining: 2m 25s\n",
      "22:\tlearn: 0.2782515\ttotal: 12s\tremaining: 2m 24s\n",
      "23:\tlearn: 0.2776294\ttotal: 12.5s\tremaining: 2m 23s\n",
      "24:\tlearn: 0.2772333\ttotal: 13s\tremaining: 2m 23s\n",
      "25:\tlearn: 0.2768003\ttotal: 13.6s\tremaining: 2m 22s\n",
      "26:\tlearn: 0.2764516\ttotal: 14s\tremaining: 2m 21s\n",
      "27:\tlearn: 0.2761037\ttotal: 14.5s\tremaining: 2m 20s\n",
      "28:\tlearn: 0.2757995\ttotal: 15s\tremaining: 2m 20s\n",
      "29:\tlearn: 0.2755404\ttotal: 15.5s\tremaining: 2m 19s\n",
      "30:\tlearn: 0.2753335\ttotal: 15.9s\tremaining: 2m 18s\n",
      "31:\tlearn: 0.2751294\ttotal: 16.5s\tremaining: 2m 17s\n",
      "32:\tlearn: 0.2749600\ttotal: 16.9s\tremaining: 2m 16s\n",
      "33:\tlearn: 0.2748096\ttotal: 17.4s\tremaining: 2m 16s\n",
      "34:\tlearn: 0.2746508\ttotal: 17.9s\tremaining: 2m 15s\n",
      "35:\tlearn: 0.2744759\ttotal: 18.5s\tremaining: 2m 15s\n",
      "36:\tlearn: 0.2743000\ttotal: 18.9s\tremaining: 2m 14s\n",
      "37:\tlearn: 0.2741494\ttotal: 19.4s\tremaining: 2m 13s\n",
      "38:\tlearn: 0.2740247\ttotal: 19.9s\tremaining: 2m 12s\n",
      "39:\tlearn: 0.2739329\ttotal: 20.4s\tremaining: 2m 12s\n",
      "40:\tlearn: 0.2738084\ttotal: 20.9s\tremaining: 2m 12s\n",
      "41:\tlearn: 0.2737103\ttotal: 21.5s\tremaining: 2m 11s\n",
      "42:\tlearn: 0.2735962\ttotal: 22s\tremaining: 2m 11s\n",
      "43:\tlearn: 0.2734955\ttotal: 22.4s\tremaining: 2m 10s\n",
      "44:\tlearn: 0.2734077\ttotal: 22.9s\tremaining: 2m 9s\n",
      "45:\tlearn: 0.2733399\ttotal: 23.4s\tremaining: 2m 9s\n",
      "46:\tlearn: 0.2732147\ttotal: 24s\tremaining: 2m 9s\n",
      "47:\tlearn: 0.2731284\ttotal: 24.6s\tremaining: 2m 9s\n",
      "48:\tlearn: 0.2730598\ttotal: 25.1s\tremaining: 2m 8s\n",
      "49:\tlearn: 0.2729952\ttotal: 25.6s\tremaining: 2m 8s\n",
      "50:\tlearn: 0.2729183\ttotal: 26.2s\tremaining: 2m 8s\n",
      "51:\tlearn: 0.2728487\ttotal: 26.8s\tremaining: 2m 7s\n",
      "52:\tlearn: 0.2727670\ttotal: 27.4s\tremaining: 2m 7s\n",
      "53:\tlearn: 0.2727061\ttotal: 27.9s\tremaining: 2m 6s\n",
      "54:\tlearn: 0.2726305\ttotal: 28.4s\tremaining: 2m 6s\n",
      "55:\tlearn: 0.2725697\ttotal: 29s\tremaining: 2m 6s\n",
      "56:\tlearn: 0.2724978\ttotal: 29.5s\tremaining: 2m 5s\n",
      "57:\tlearn: 0.2724327\ttotal: 29.9s\tremaining: 2m 4s\n",
      "58:\tlearn: 0.2723599\ttotal: 30.4s\tremaining: 2m 3s\n",
      "59:\tlearn: 0.2723106\ttotal: 30.9s\tremaining: 2m 3s\n",
      "60:\tlearn: 0.2722603\ttotal: 31.4s\tremaining: 2m 2s\n",
      "61:\tlearn: 0.2722100\ttotal: 31.8s\tremaining: 2m 2s\n",
      "62:\tlearn: 0.2721508\ttotal: 32.3s\tremaining: 2m 1s\n",
      "63:\tlearn: 0.2721004\ttotal: 32.8s\tremaining: 2m\n",
      "64:\tlearn: 0.2720448\ttotal: 33.3s\tremaining: 2m\n",
      "65:\tlearn: 0.2719740\ttotal: 33.7s\tremaining: 1m 59s\n",
      "66:\tlearn: 0.2719150\ttotal: 34.2s\tremaining: 1m 58s\n",
      "67:\tlearn: 0.2718503\ttotal: 34.6s\tremaining: 1m 58s\n",
      "68:\tlearn: 0.2718010\ttotal: 35.1s\tremaining: 1m 57s\n",
      "69:\tlearn: 0.2717310\ttotal: 35.6s\tremaining: 1m 57s\n",
      "70:\tlearn: 0.2716921\ttotal: 36.1s\tremaining: 1m 56s\n",
      "71:\tlearn: 0.2716118\ttotal: 37.4s\tremaining: 1m 58s\n",
      "72:\tlearn: 0.2715527\ttotal: 37.8s\tremaining: 1m 57s\n",
      "73:\tlearn: 0.2715115\ttotal: 38.3s\tremaining: 1m 56s\n",
      "74:\tlearn: 0.2714582\ttotal: 38.7s\tremaining: 1m 56s\n",
      "75:\tlearn: 0.2714228\ttotal: 39.2s\tremaining: 1m 55s\n",
      "76:\tlearn: 0.2713428\ttotal: 39.7s\tremaining: 1m 55s\n",
      "77:\tlearn: 0.2713086\ttotal: 40.2s\tremaining: 1m 54s\n",
      "78:\tlearn: 0.2712682\ttotal: 40.7s\tremaining: 1m 53s\n",
      "79:\tlearn: 0.2712123\ttotal: 41.1s\tremaining: 1m 53s\n",
      "80:\tlearn: 0.2711785\ttotal: 41.6s\tremaining: 1m 52s\n",
      "81:\tlearn: 0.2711087\ttotal: 42.1s\tremaining: 1m 51s\n",
      "82:\tlearn: 0.2710730\ttotal: 42.5s\tremaining: 1m 51s\n",
      "83:\tlearn: 0.2710132\ttotal: 42.9s\tremaining: 1m 50s\n",
      "84:\tlearn: 0.2709664\ttotal: 43.5s\tremaining: 1m 49s\n",
      "85:\tlearn: 0.2709390\ttotal: 43.9s\tremaining: 1m 49s\n",
      "86:\tlearn: 0.2708896\ttotal: 44.4s\tremaining: 1m 48s\n",
      "87:\tlearn: 0.2708565\ttotal: 44.9s\tremaining: 1m 48s\n",
      "88:\tlearn: 0.2708241\ttotal: 45.4s\tremaining: 1m 47s\n",
      "89:\tlearn: 0.2707728\ttotal: 45.9s\tremaining: 1m 47s\n",
      "90:\tlearn: 0.2707403\ttotal: 46.4s\tremaining: 1m 46s\n",
      "91:\tlearn: 0.2706926\ttotal: 46.8s\tremaining: 1m 45s\n",
      "92:\tlearn: 0.2706669\ttotal: 47.3s\tremaining: 1m 45s\n",
      "93:\tlearn: 0.2706357\ttotal: 47.8s\tremaining: 1m 44s\n",
      "94:\tlearn: 0.2705976\ttotal: 48.3s\tremaining: 1m 44s\n",
      "95:\tlearn: 0.2705609\ttotal: 48.8s\tremaining: 1m 43s\n",
      "96:\tlearn: 0.2705360\ttotal: 49.4s\tremaining: 1m 43s\n",
      "97:\tlearn: 0.2704969\ttotal: 49.9s\tremaining: 1m 42s\n",
      "98:\tlearn: 0.2704558\ttotal: 50.4s\tremaining: 1m 42s\n",
      "99:\tlearn: 0.2704185\ttotal: 50.8s\tremaining: 1m 41s\n",
      "100:\tlearn: 0.2703852\ttotal: 51.3s\tremaining: 1m 41s\n",
      "101:\tlearn: 0.2703458\ttotal: 51.9s\tremaining: 1m 40s\n",
      "102:\tlearn: 0.2703192\ttotal: 52.4s\tremaining: 1m 40s\n",
      "103:\tlearn: 0.2703081\ttotal: 52.8s\tremaining: 1m 39s\n",
      "104:\tlearn: 0.2702842\ttotal: 53.3s\tremaining: 1m 38s\n",
      "105:\tlearn: 0.2702547\ttotal: 53.8s\tremaining: 1m 38s\n",
      "106:\tlearn: 0.2702239\ttotal: 54.3s\tremaining: 1m 37s\n",
      "107:\tlearn: 0.2701957\ttotal: 55s\tremaining: 1m 37s\n",
      "108:\tlearn: 0.2701513\ttotal: 55.5s\tremaining: 1m 37s\n",
      "109:\tlearn: 0.2701191\ttotal: 56s\tremaining: 1m 36s\n",
      "110:\tlearn: 0.2700940\ttotal: 56.5s\tremaining: 1m 36s\n",
      "111:\tlearn: 0.2700623\ttotal: 57.1s\tremaining: 1m 35s\n",
      "112:\tlearn: 0.2700381\ttotal: 57.6s\tremaining: 1m 35s\n",
      "113:\tlearn: 0.2700139\ttotal: 58.2s\tremaining: 1m 34s\n",
      "114:\tlearn: 0.2699855\ttotal: 58.7s\tremaining: 1m 34s\n",
      "115:\tlearn: 0.2699472\ttotal: 59.3s\tremaining: 1m 34s\n",
      "116:\tlearn: 0.2699268\ttotal: 59.8s\tremaining: 1m 33s\n",
      "117:\tlearn: 0.2698983\ttotal: 1m\tremaining: 1m 32s\n",
      "118:\tlearn: 0.2698807\ttotal: 1m\tremaining: 1m 32s\n",
      "119:\tlearn: 0.2698600\ttotal: 1m 1s\tremaining: 1m 31s\n",
      "120:\tlearn: 0.2698235\ttotal: 1m 1s\tremaining: 1m 31s\n",
      "121:\tlearn: 0.2698015\ttotal: 1m 2s\tremaining: 1m 30s\n",
      "122:\tlearn: 0.2697776\ttotal: 1m 2s\tremaining: 1m 30s\n",
      "123:\tlearn: 0.2697520\ttotal: 1m 3s\tremaining: 1m 29s\n",
      "124:\tlearn: 0.2697259\ttotal: 1m 3s\tremaining: 1m 29s\n",
      "125:\tlearn: 0.2697031\ttotal: 1m 4s\tremaining: 1m 28s\n",
      "126:\tlearn: 0.2696761\ttotal: 1m 4s\tremaining: 1m 28s\n",
      "127:\tlearn: 0.2696339\ttotal: 1m 5s\tremaining: 1m 27s\n",
      "128:\tlearn: 0.2696114\ttotal: 1m 5s\tremaining: 1m 27s\n",
      "129:\tlearn: 0.2695903\ttotal: 1m 6s\tremaining: 1m 26s\n",
      "130:\tlearn: 0.2695650\ttotal: 1m 6s\tremaining: 1m 26s\n",
      "131:\tlearn: 0.2695402\ttotal: 1m 7s\tremaining: 1m 25s\n",
      "132:\tlearn: 0.2695161\ttotal: 1m 7s\tremaining: 1m 25s\n",
      "133:\tlearn: 0.2694868\ttotal: 1m 8s\tremaining: 1m 24s\n",
      "134:\tlearn: 0.2694629\ttotal: 1m 8s\tremaining: 1m 23s\n",
      "135:\tlearn: 0.2694440\ttotal: 1m 9s\tremaining: 1m 23s\n",
      "136:\tlearn: 0.2694191\ttotal: 1m 9s\tremaining: 1m 22s\n",
      "137:\tlearn: 0.2693964\ttotal: 1m 10s\tremaining: 1m 22s\n",
      "138:\tlearn: 0.2693789\ttotal: 1m 10s\tremaining: 1m 21s\n",
      "139:\tlearn: 0.2693522\ttotal: 1m 11s\tremaining: 1m 21s\n",
      "140:\tlearn: 0.2693318\ttotal: 1m 11s\tremaining: 1m 20s\n",
      "141:\tlearn: 0.2692985\ttotal: 1m 12s\tremaining: 1m 20s\n",
      "142:\tlearn: 0.2692746\ttotal: 1m 12s\tremaining: 1m 19s\n",
      "143:\tlearn: 0.2692549\ttotal: 1m 13s\tremaining: 1m 19s\n",
      "144:\tlearn: 0.2692345\ttotal: 1m 13s\tremaining: 1m 18s\n",
      "145:\tlearn: 0.2692192\ttotal: 1m 14s\tremaining: 1m 18s\n",
      "146:\tlearn: 0.2692030\ttotal: 1m 14s\tremaining: 1m 17s\n",
      "147:\tlearn: 0.2691846\ttotal: 1m 15s\tremaining: 1m 17s\n",
      "148:\tlearn: 0.2691649\ttotal: 1m 15s\tremaining: 1m 16s\n",
      "149:\tlearn: 0.2691351\ttotal: 1m 16s\tremaining: 1m 16s\n",
      "150:\tlearn: 0.2691172\ttotal: 1m 16s\tremaining: 1m 15s\n",
      "151:\tlearn: 0.2690976\ttotal: 1m 17s\tremaining: 1m 15s\n",
      "152:\tlearn: 0.2690744\ttotal: 1m 17s\tremaining: 1m 14s\n",
      "153:\tlearn: 0.2690489\ttotal: 1m 18s\tremaining: 1m 14s\n",
      "154:\tlearn: 0.2690281\ttotal: 1m 18s\tremaining: 1m 13s\n",
      "155:\tlearn: 0.2690069\ttotal: 1m 19s\tremaining: 1m 13s\n",
      "156:\tlearn: 0.2689886\ttotal: 1m 19s\tremaining: 1m 12s\n",
      "157:\tlearn: 0.2689708\ttotal: 1m 20s\tremaining: 1m 12s\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "158:\tlearn: 0.2689558\ttotal: 1m 20s\tremaining: 1m 11s\n",
      "159:\tlearn: 0.2689389\ttotal: 1m 21s\tremaining: 1m 11s\n",
      "160:\tlearn: 0.2689273\ttotal: 1m 21s\tremaining: 1m 10s\n",
      "161:\tlearn: 0.2689062\ttotal: 1m 22s\tremaining: 1m 10s\n",
      "162:\tlearn: 0.2688837\ttotal: 1m 22s\tremaining: 1m 9s\n",
      "163:\tlearn: 0.2688722\ttotal: 1m 23s\tremaining: 1m 9s\n",
      "164:\tlearn: 0.2688602\ttotal: 1m 23s\tremaining: 1m 8s\n",
      "165:\tlearn: 0.2688419\ttotal: 1m 24s\tremaining: 1m 7s\n",
      "166:\tlearn: 0.2688311\ttotal: 1m 24s\tremaining: 1m 7s\n",
      "167:\tlearn: 0.2688143\ttotal: 1m 25s\tremaining: 1m 6s\n",
      "168:\tlearn: 0.2687947\ttotal: 1m 25s\tremaining: 1m 6s\n",
      "169:\tlearn: 0.2687703\ttotal: 1m 26s\tremaining: 1m 5s\n",
      "170:\tlearn: 0.2687481\ttotal: 1m 26s\tremaining: 1m 5s\n",
      "171:\tlearn: 0.2687167\ttotal: 1m 27s\tremaining: 1m 4s\n",
      "172:\tlearn: 0.2686880\ttotal: 1m 27s\tremaining: 1m 4s\n",
      "173:\tlearn: 0.2686678\ttotal: 1m 28s\tremaining: 1m 3s\n",
      "174:\tlearn: 0.2686523\ttotal: 1m 28s\tremaining: 1m 3s\n",
      "175:\tlearn: 0.2686358\ttotal: 1m 29s\tremaining: 1m 2s\n",
      "176:\tlearn: 0.2686162\ttotal: 1m 29s\tremaining: 1m 2s\n",
      "177:\tlearn: 0.2685984\ttotal: 1m 30s\tremaining: 1m 1s\n",
      "178:\tlearn: 0.2685749\ttotal: 1m 30s\tremaining: 1m 1s\n",
      "179:\tlearn: 0.2685654\ttotal: 1m 30s\tremaining: 1m\n",
      "180:\tlearn: 0.2685436\ttotal: 1m 31s\tremaining: 1m\n",
      "181:\tlearn: 0.2685312\ttotal: 1m 31s\tremaining: 59.6s\n",
      "182:\tlearn: 0.2685169\ttotal: 1m 32s\tremaining: 59.1s\n",
      "183:\tlearn: 0.2684946\ttotal: 1m 32s\tremaining: 58.5s\n",
      "184:\tlearn: 0.2684647\ttotal: 1m 33s\tremaining: 58s\n",
      "185:\tlearn: 0.2684486\ttotal: 1m 33s\tremaining: 57.5s\n",
      "186:\tlearn: 0.2684308\ttotal: 1m 34s\tremaining: 57s\n",
      "187:\tlearn: 0.2684148\ttotal: 1m 34s\tremaining: 56.5s\n",
      "188:\tlearn: 0.2683936\ttotal: 1m 35s\tremaining: 56s\n",
      "189:\tlearn: 0.2683785\ttotal: 1m 35s\tremaining: 55.5s\n",
      "190:\tlearn: 0.2683670\ttotal: 1m 36s\tremaining: 55s\n",
      "191:\tlearn: 0.2683416\ttotal: 1m 36s\tremaining: 54.5s\n",
      "192:\tlearn: 0.2683321\ttotal: 1m 37s\tremaining: 53.9s\n",
      "193:\tlearn: 0.2683155\ttotal: 1m 37s\tremaining: 53.4s\n",
      "194:\tlearn: 0.2682979\ttotal: 1m 38s\tremaining: 52.9s\n",
      "195:\tlearn: 0.2682730\ttotal: 1m 38s\tremaining: 52.5s\n",
      "196:\tlearn: 0.2682627\ttotal: 1m 39s\tremaining: 51.9s\n",
      "197:\tlearn: 0.2682430\ttotal: 1m 39s\tremaining: 51.4s\n",
      "198:\tlearn: 0.2682279\ttotal: 1m 40s\tremaining: 50.9s\n",
      "199:\tlearn: 0.2682177\ttotal: 1m 40s\tremaining: 50.4s\n",
      "200:\tlearn: 0.2681975\ttotal: 1m 41s\tremaining: 49.9s\n",
      "201:\tlearn: 0.2681854\ttotal: 1m 41s\tremaining: 49.3s\n",
      "202:\tlearn: 0.2681557\ttotal: 1m 42s\tremaining: 48.9s\n",
      "203:\tlearn: 0.2681451\ttotal: 1m 42s\tremaining: 48.3s\n",
      "204:\tlearn: 0.2681250\ttotal: 1m 43s\tremaining: 47.8s\n",
      "205:\tlearn: 0.2681095\ttotal: 1m 43s\tremaining: 47.3s\n",
      "206:\tlearn: 0.2681000\ttotal: 1m 44s\tremaining: 46.8s\n",
      "207:\tlearn: 0.2680911\ttotal: 1m 44s\tremaining: 46.2s\n",
      "208:\tlearn: 0.2680806\ttotal: 1m 45s\tremaining: 45.7s\n",
      "209:\tlearn: 0.2680688\ttotal: 1m 45s\tremaining: 45.2s\n",
      "210:\tlearn: 0.2680423\ttotal: 1m 45s\tremaining: 44.7s\n",
      "211:\tlearn: 0.2680267\ttotal: 1m 46s\tremaining: 44.2s\n",
      "212:\tlearn: 0.2680148\ttotal: 1m 47s\tremaining: 43.7s\n",
      "213:\tlearn: 0.2679986\ttotal: 1m 47s\tremaining: 43.2s\n",
      "214:\tlearn: 0.2679761\ttotal: 1m 48s\tremaining: 42.7s\n",
      "215:\tlearn: 0.2679602\ttotal: 1m 48s\tremaining: 42.2s\n",
      "216:\tlearn: 0.2679475\ttotal: 1m 49s\tremaining: 41.7s\n",
      "217:\tlearn: 0.2679325\ttotal: 1m 49s\tremaining: 41.3s\n",
      "218:\tlearn: 0.2679192\ttotal: 1m 50s\tremaining: 40.8s\n",
      "219:\tlearn: 0.2679044\ttotal: 1m 50s\tremaining: 40.3s\n",
      "220:\tlearn: 0.2678915\ttotal: 1m 51s\tremaining: 39.7s\n",
      "221:\tlearn: 0.2678813\ttotal: 1m 51s\tremaining: 39.2s\n",
      "222:\tlearn: 0.2678601\ttotal: 1m 52s\tremaining: 38.7s\n",
      "223:\tlearn: 0.2678457\ttotal: 1m 52s\tremaining: 38.2s\n",
      "224:\tlearn: 0.2678343\ttotal: 1m 53s\tremaining: 37.7s\n",
      "225:\tlearn: 0.2678263\ttotal: 1m 53s\tremaining: 37.2s\n",
      "226:\tlearn: 0.2678135\ttotal: 1m 53s\tremaining: 36.6s\n",
      "227:\tlearn: 0.2677968\ttotal: 1m 54s\tremaining: 36.1s\n",
      "228:\tlearn: 0.2677817\ttotal: 1m 54s\tremaining: 35.6s\n",
      "229:\tlearn: 0.2677639\ttotal: 1m 55s\tremaining: 35.1s\n",
      "230:\tlearn: 0.2677553\ttotal: 1m 55s\tremaining: 34.6s\n",
      "231:\tlearn: 0.2677438\ttotal: 1m 56s\tremaining: 34.1s\n",
      "232:\tlearn: 0.2677354\ttotal: 1m 56s\tremaining: 33.6s\n",
      "233:\tlearn: 0.2677196\ttotal: 1m 57s\tremaining: 33.1s\n",
      "234:\tlearn: 0.2677084\ttotal: 1m 57s\tremaining: 32.6s\n",
      "235:\tlearn: 0.2676964\ttotal: 1m 58s\tremaining: 32.1s\n",
      "236:\tlearn: 0.2676864\ttotal: 1m 58s\tremaining: 31.6s\n",
      "237:\tlearn: 0.2676708\ttotal: 1m 59s\tremaining: 31.1s\n",
      "238:\tlearn: 0.2676580\ttotal: 1m 59s\tremaining: 30.6s\n",
      "239:\tlearn: 0.2676386\ttotal: 2m\tremaining: 30.1s\n",
      "240:\tlearn: 0.2676212\ttotal: 2m\tremaining: 29.6s\n",
      "241:\tlearn: 0.2676087\ttotal: 2m 1s\tremaining: 29.1s\n",
      "242:\tlearn: 0.2676002\ttotal: 2m 1s\tremaining: 28.6s\n",
      "243:\tlearn: 0.2675860\ttotal: 2m 2s\tremaining: 28.1s\n",
      "244:\tlearn: 0.2675760\ttotal: 2m 2s\tremaining: 27.6s\n",
      "245:\tlearn: 0.2675625\ttotal: 2m 3s\tremaining: 27.1s\n",
      "246:\tlearn: 0.2675538\ttotal: 2m 3s\tremaining: 26.6s\n",
      "247:\tlearn: 0.2675432\ttotal: 2m 4s\tremaining: 26.1s\n",
      "248:\tlearn: 0.2675295\ttotal: 2m 4s\tremaining: 25.6s\n",
      "249:\tlearn: 0.2675231\ttotal: 2m 5s\tremaining: 25.1s\n",
      "250:\tlearn: 0.2675140\ttotal: 2m 5s\tremaining: 24.6s\n",
      "251:\tlearn: 0.2675031\ttotal: 2m 6s\tremaining: 24s\n",
      "252:\tlearn: 0.2674841\ttotal: 2m 6s\tremaining: 23.5s\n",
      "253:\tlearn: 0.2674752\ttotal: 2m 7s\tremaining: 23s\n",
      "254:\tlearn: 0.2674671\ttotal: 2m 7s\tremaining: 22.5s\n",
      "255:\tlearn: 0.2674572\ttotal: 2m 8s\tremaining: 22s\n",
      "256:\tlearn: 0.2674466\ttotal: 2m 8s\tremaining: 21.5s\n",
      "257:\tlearn: 0.2674283\ttotal: 2m 9s\tremaining: 21s\n",
      "258:\tlearn: 0.2674150\ttotal: 2m 9s\tremaining: 20.5s\n",
      "259:\tlearn: 0.2674016\ttotal: 2m 10s\tremaining: 20s\n",
      "260:\tlearn: 0.2673913\ttotal: 2m 10s\tremaining: 19.5s\n",
      "261:\tlearn: 0.2673845\ttotal: 2m 11s\tremaining: 19s\n",
      "262:\tlearn: 0.2673767\ttotal: 2m 11s\tremaining: 18.5s\n",
      "263:\tlearn: 0.2673676\ttotal: 2m 12s\tremaining: 18s\n",
      "264:\tlearn: 0.2673518\ttotal: 2m 12s\tremaining: 17.5s\n",
      "265:\tlearn: 0.2673440\ttotal: 2m 12s\tremaining: 17s\n",
      "266:\tlearn: 0.2673313\ttotal: 2m 13s\tremaining: 16.5s\n",
      "267:\tlearn: 0.2673196\ttotal: 2m 13s\tremaining: 16s\n",
      "268:\tlearn: 0.2673136\ttotal: 2m 14s\tremaining: 15.5s\n",
      "269:\tlearn: 0.2672997\ttotal: 2m 14s\tremaining: 15s\n",
      "270:\tlearn: 0.2672870\ttotal: 2m 15s\tremaining: 14.5s\n",
      "271:\tlearn: 0.2672794\ttotal: 2m 15s\tremaining: 14s\n",
      "272:\tlearn: 0.2672730\ttotal: 2m 16s\tremaining: 13.5s\n",
      "273:\tlearn: 0.2672598\ttotal: 2m 16s\tremaining: 13s\n",
      "274:\tlearn: 0.2672510\ttotal: 2m 17s\tremaining: 12.5s\n",
      "275:\tlearn: 0.2672349\ttotal: 2m 17s\tremaining: 12s\n",
      "276:\tlearn: 0.2672298\ttotal: 2m 18s\tremaining: 11.5s\n",
      "277:\tlearn: 0.2672192\ttotal: 2m 18s\tremaining: 11s\n",
      "278:\tlearn: 0.2672115\ttotal: 2m 19s\tremaining: 10.5s\n",
      "279:\tlearn: 0.2672013\ttotal: 2m 19s\tremaining: 9.98s\n",
      "280:\tlearn: 0.2671907\ttotal: 2m 20s\tremaining: 9.48s\n",
      "281:\tlearn: 0.2671842\ttotal: 2m 20s\tremaining: 8.97s\n",
      "282:\tlearn: 0.2671775\ttotal: 2m 21s\tremaining: 8.47s\n",
      "283:\tlearn: 0.2671718\ttotal: 2m 21s\tremaining: 7.97s\n",
      "284:\tlearn: 0.2671522\ttotal: 2m 22s\tremaining: 7.48s\n",
      "285:\tlearn: 0.2671431\ttotal: 2m 22s\tremaining: 6.99s\n",
      "286:\tlearn: 0.2671274\ttotal: 2m 23s\tremaining: 6.49s\n",
      "287:\tlearn: 0.2671200\ttotal: 2m 23s\tremaining: 5.99s\n",
      "288:\tlearn: 0.2671056\ttotal: 2m 24s\tremaining: 5.49s\n",
      "289:\tlearn: 0.2670975\ttotal: 2m 24s\tremaining: 4.99s\n",
      "290:\tlearn: 0.2670885\ttotal: 2m 25s\tremaining: 4.5s\n",
      "291:\tlearn: 0.2670799\ttotal: 2m 25s\tremaining: 4s\n",
      "292:\tlearn: 0.2670658\ttotal: 2m 26s\tremaining: 3.5s\n",
      "293:\tlearn: 0.2670562\ttotal: 2m 26s\tremaining: 3s\n",
      "294:\tlearn: 0.2670460\ttotal: 2m 27s\tremaining: 2.5s\n",
      "295:\tlearn: 0.2670321\ttotal: 2m 27s\tremaining: 2s\n",
      "296:\tlearn: 0.2670180\ttotal: 2m 28s\tremaining: 1.5s\n",
      "297:\tlearn: 0.2670094\ttotal: 2m 28s\tremaining: 998ms\n",
      "298:\tlearn: 0.2670013\ttotal: 2m 29s\tremaining: 500ms\n",
      "299:\tlearn: 0.2669893\ttotal: 2m 30s\tremaining: 0us\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<catboost.core.CatBoostClassifier at 0x7f8f45214630>"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cbt_model = cat.CatBoostClassifier(iterations=300,learning_rate=0.1,depth=5,verbose=True,thread_count=12\n",
    "                                   ,random_seed=1024)\n",
    "cbt_model.fit(recall_train[features], recall_train['label'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": [
    "cbt_model.save_model('model0924_base.file')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "importance = dict(zip(features,\n",
    "cbt_model.feature_importances_))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('apriori', 27.28756987244248),\n",
       " ('itemID_median', 8.290965095145731),\n",
       " ('user_to_category_lastday', 7.07994210784468),\n",
       " ('user_to_category_count_buy', 5.7383039412964445),\n",
       " ('user_to_category_count_pv_5days', 5.523705076092089),\n",
       " ('user_to_category_count_pv', 3.6634786916021396),\n",
       " ('itemID_std', 2.973804811358111),\n",
       " ('user_to_category_count_buy_yestday', 2.9720553018294242),\n",
       " ('user_to_age_count', 2.4646399997374417),\n",
       " ('user_to_sex_count', 2.409206256237985),\n",
       " ('user_to_category_lasttime', 2.319085627011794),\n",
       " ('user_to_category_count_pv_yestday', 1.96984573441514),\n",
       " ('age', 1.757174970832472),\n",
       " ('itemID_skew', 1.5063951577357892),\n",
       " ('user_to_shop_count_pv', 1.4966560077500304),\n",
       " ('user_to_category_count_buy_5days', 1.3092884271919525),\n",
       " ('rank', 1.1516030170793725),\n",
       " ('category_count', 1.147464644646628),\n",
       " ('user_to_category_count_5days', 1.1221689244633937),\n",
       " ('category_std', 1.0918870855320673),\n",
       " ('itemID_count', 1.0201773241728571),\n",
       " ('shop_count', 1.0185020472919601),\n",
       " ('user_to_brand_count_pv', 1.0067128105572412),\n",
       " ('user_to_brand_sum', 0.954042675110285),\n",
       " ('user_to_shop_count', 0.9305873028137963),\n",
       " ('ability', 0.8277866337425583),\n",
       " ('user_to_ability_count', 0.7111652189901285),\n",
       " ('brand_count', 0.7090070158121335),\n",
       " ('category_median', 0.681949062526269),\n",
       " ('user_to_brand_count_buy_5days', 0.6600978426957829),\n",
       " ('user_to_brand_count', 0.6417751744994954),\n",
       " ('user_to_category_count_yestday', 0.6290691411487302),\n",
       " ('itemIDlast_time', 0.622966509690606),\n",
       " ('user_to_shop_lasttime', 0.5539912728824887),\n",
       " ('itemID_sum', 0.54067425249639),\n",
       " ('shop_sum', 0.528248736432499),\n",
       " ('brandnum_undercat', 0.36279276742454236),\n",
       " ('user_to_shop_lastday', 0.345745637579721),\n",
       " ('user_to_brand_lasttime', 0.3392726529975986),\n",
       " ('brand_sum', 0.30243324290767826),\n",
       " ('category_sum', 0.2972347540153292),\n",
       " ('user_to_category_count', 0.28108372105321255),\n",
       " ('user_to_shop_count_buy_yestday', 0.26669841669374117),\n",
       " ('user_to_shop_count_buy', 0.23086734344251975),\n",
       " ('user_to_shop_sum', 0.22227705993173602),\n",
       " ('category_skew', 0.21843835730022557),\n",
       " ('rank_percent', 0.21651442093132778),\n",
       " ('user_to_shop_count_pv_yestday', 0.207861807960456),\n",
       " ('user_to_brand_count_buy_yestday', 0.20075945763028505),\n",
       " ('user_to_brand_lastday', 0.18717325139595967),\n",
       " ('shopnum_undercat', 0.17816407228526177),\n",
       " ('shoplast_time', 0.16195270764915062),\n",
       " ('user_to_brand_count_pv_yestday', 0.15628142224579591),\n",
       " ('itemnum_undercat', 0.14901844877622533),\n",
       " ('user_to_category_sum', 0.11326634266490741),\n",
       " ('user_to_brand_count_buy', 0.0763461944218196),\n",
       " ('shoplast_time_hour_ed', 0.06747842920014958),\n",
       " ('user_to_shop_count_buy_5days', 0.04868805672848317),\n",
       " ('user_to_brand_count_pv_5days', 0.026816613726960085),\n",
       " ('user_to_shop_count_pv_5days', 0.014712047290010712),\n",
       " ('sex', 0.013405393491663675),\n",
       " ('itemIDlast_time_hour_ed', 0.002723609146835795),\n",
       " ('brandlast_time', 0.0),\n",
       " ('brandlast_time_hour_ed', 0.0)]"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sorted(importance.items(), key=lambda x:x[1], reverse=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#####要有LGB和融合的代码！！！！！！！！"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
